#pragma oncce
#include<iostream>
#include<ctime>
#include<string>

using std::cin;
using std::cerr;
using std::endl;
using std::string;

#define INFO 1
#define WARENING 2
#define ERROR  3
#define FATAL 4

#define LOG(level,message) class_LOG::Log(#level,message,time(nullptr),__FILE__,__LINE__)

#ifndef LOG_HPP  // 唯一宏名（建议与文件名相关）
#define LOG_HPP

class class_LOG
{
    public:
    static void Log(string level,string message,int time,string file_name,int line)
    {
        cerr<<"["<<level<<"]";
        cerr<<"["<<convertTimeStamp2TimeStr(time)<<"]";
        cerr<<"["<<message<<"]"<<"["<<file_name<<"]"<<"["<<line<<"]"<<endl;
    }
   
    
    //将时间戳转变为正常时间

    // struct tm {
    //            int tm_sec;    /* Seconds (0-60) */
    //            int tm_min;    /* Minutes (0-59) */
    //            int tm_hour;   /* Hours (0-23) */
    //            int tm_mday;   /* Day of the month (1-31) */
    //            int tm_mon;    /* Month (0-11) */
    //            int tm_year;   /* Year - 1900 */
    //            int tm_wday;   /* Day of the week (0-6, Sunday = 0) */
    //            int tm_yday;   /* Day in the year (0-365, 1 Jan = 0) */
    //            int tm_isdst;  /* Daylight saving time */
    //        };
    // struct tm *localtime(const time_t *timep);
    // size_t strftime(char *s, size_t max, const char *format,const struct tm *tm);

    static string convertTimeStamp2TimeStr(time_t timeStamp) {
        struct tm *timeinfo = nullptr;
        char buffer[80];
        timeinfo = localtime(&timeStamp);
        strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
        return string(buffer);
        }


};

#endif

